"""请求封装"""
import allure
import pymysql
import requests

from utils.exception_utils import *
from utils.logger_utils import *
from utils.mysql_utils import MysqlUtils


@allure.step("2、发送请求")
def send_request(req_data):
    try:
        r = requests.request(**req_data)
        return r
    except Exception as e:
        info(f"发起请求异常！{e}")
        raise ReqException

def send_sql(sql):
    try:
        if sql is not None:
            row = MysqlUtils().send_sql_one(sql)
            return row
        else:
            return []
    except Exception as e:
        info(f"sql请求异常！{e}")
        raise SqlException